package fr.pud.client.view;

import java.awt.BorderLayout;

import javax.swing.JFrame;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import fr.pud.client.i18n.LanguagesConstants;

/**
 * 3 avr. 2012 - Projet_Ose
 * @author Simon Devineau, Adrien Hierry, Leopold Houdin, Pierre Reliquet
 *         Ecole des Mines de Nantes
 *         ProgressFrameforCSV.java
 *         This class creates a frame where the progression of a CSV file (which
 *         contains addresses) will be represented.
 */
public class ProgressFrameForCSV extends JFrame {
    private static final long serialVersionUID = 7587035826776834094L;
    /**
     * The {@link JProgressBar} of the frame.
     */
    private JProgressBar      myProgressBar;
    /**
     * The {@link JTextArea} where the current line read will be drawn.
     */
    private JTextArea         textArea;

    /**
     * The constructor.
     */
    public ProgressFrameForCSV() {
        super(LanguagesConstants.LANGUAGE
                .getString(LanguagesConstants.LOADING_ADDRESSES));
        this.prepareProgressBar();
        this.prepareTexteArea();
        this.setVisible(true);
        this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        this.pack();
        this.setLocation(JMapViewerExtended.getJMapViewer().getLocation());
    }

    /**
     * @return the myProgressBar
     */
    public JProgressBar getMyProgressBar() {
        return this.myProgressBar;
    }

    /**
     * @return the textArea
     */
    public JTextArea getTextArea() {
        return this.textArea;
    }

    /**
     * Prepare the JProgressBar of the frame.
     */
    private void prepareProgressBar() {
        this.myProgressBar = new JProgressBar(0, 99);
        this.myProgressBar.setStringPainted(true);
        this.add(this.myProgressBar, BorderLayout.SOUTH);
    }

    /**
     * Prepare the JTextArea of the frame.
     */
    private void prepareTexteArea() {
        this.textArea = new JTextArea(10, 40);
        JScrollPane scroll = new JScrollPane(this.getTextArea());
        this.add(scroll, BorderLayout.CENTER);
    }
}
